package control;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DatabaseConnect{
	public static String standardIP="10.1.120.20";
	Connection conn = null;
	
	public DatabaseConnect(){
		//connect();
		//getConnection();
	}
	
	public Connection connect(){		
		try{
			String userName = "root";
			String password = "root";
		    String url = "jdbc:mysql://"+DatabaseConnect.standardIP+"/anves";
	        Class.forName ("com.mysql.jdbc.Driver").newInstance ();
	        conn = DriverManager.getConnection (url, userName, password);
	        System.out.println ("Datenbankverbindung hergerstellt");
		}catch (Exception e){
			System.err.println ("Fehler bei der Datenbankverbindung!");
		}		
		return conn;
	}
	
	public void DatabaseClose(Connection conn){
		try{
			conn.close();
			System.out.print("Verbindung geschlossen");
		} catch (SQLException e){
			e.printStackTrace();
		}		
	}
	
	public void closeConnection(){		
		try{
			conn.close();
			System.out.print("Verbindung geschlossen");
		} catch (SQLException e){
			e.printStackTrace();
		}	
	}	
   
}